package main
import(
	"fmt"
)

func main(){
  //定义切片
  var arr = [6]int{1,3,4,5,6,8}
  //3.1省略0开头
  var slice []int = arr[:3]
  //3.2省略n到末尾
  var slice1 []int = arr[4:]
  //3.3/4.切片继续切片，全切只写:
  slice2 := slice[:]
  //修改会改原值
  slice2[1] = 55

  fmt.Println(slice)
  fmt.Println(slice1)
  fmt.Println(slice2)
  fmt.Println("切片slice2的长度：",len(slice))
  fmt.Println("切片slice2的容量：",cap(slice))
  //5.追加,产出新数组再追加
  slice4 := append(slice,88,77)
  fmt.Println(slice4)
  fmt.Println(slice)
  //要改原来的，重新赋值
  slice = append(slice,88,77)
  fmt.Println(slice)
  //切片追加给切片
  slice5 := []int{99,88}
  slice = append(slice,slice5...)
  fmt.Println(slice)
  //6.切片的拷贝
  var b[]int = make([]int,10)
  copy(b,slice)
  fmt.Println(b)

}
